package com.neusoft.controller;

import com.neusoft.model.OrderSearch;
import com.neusoft.po.Package;
import com.neusoft.service.PackageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 收藏夹请求控制器
 *
 * @author Lucifer
 * @since 2021/5/16 21:37
 */
@RestController
@RequestMapping("/package")
@Api(tags = "收藏夹接口")
public class PackageController {

    @Resource
    private PackageService packageService;

    @PostMapping("page")
    @ApiOperation("收藏夹下的所有商品")
    public Object get(@RequestBody OrderSearch orderSearch) {
        return packageService.page(orderSearch);
    }

    @PostMapping
    @ApiOperation("单个商品收藏")
    public Integer save(@RequestBody Package pack) {
        packageService.save(pack);
        return pack.getId();
    }

    @DeleteMapping("/remove")
    @ApiOperation("删除（新增，修改同）")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "商品ID集合", name = "ids", required = true),
            @ApiImplicitParam(value = "用户ID", name = "user_id", required = true),
    })
    public void delete(Integer[] ids, Integer user_id) {
        packageService.remove(ids, user_id);
    }
}
